package com.sixth.service.impl;

import com.sixth.bean.MarketAdmin;
import com.sixth.bean.MarketAdminExample;
import com.sixth.mapper.MarketAdminMapper;
import com.sixth.service.AdminAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClassName AdminAuthServiceImpl
 * @Description TODO
 * @Author XiaoWJ
 * @Date 2022/9/12 17:09
 **/
@Service
public class AdminAuthServiceImpl implements AdminAuthService {

    @Autowired
    MarketAdminMapper marketAdminMapper;


    @Override
    public void updateLastLoginIpAndTime(MarketAdmin marketAdmin,String ip) {
        marketAdmin.setLastLoginTime(new Date());
        marketAdmin.setLastLoginIp(ip);

        MarketAdminExample example = new MarketAdminExample();

        MarketAdminExample.Criteria criteria = example.createCriteria();

        criteria.andIdEqualTo(marketAdmin.getId()).andDeletedEqualTo(false);

        marketAdminMapper.updateByExampleSelective(marketAdmin,example);
    }
}
